from django.db import models

# Create your models here.

from django.db import models

from utils.base_models import BaseModel


class Interface(BaseModel):
    TYPE_CHOICES = [('1', '项目接口'), ('2', '外部接口')]
    name = models.CharField(verbose_name='接口名称', help_text='接口名称', unique=True, max_length=50)
    url = models.CharField(verbose_name='接口URL', help_text='接口URL', max_length=200)
    method = models.CharField(verbose_name='请求方式', help_text='请求方式', max_length=10)
    type = models.CharField(verbose_name='接口类型', help_text='接口类型', max_length=1, choices=TYPE_CHOICES, default='1')
    project = models.ForeignKey(verbose_name='所属项目', help_text='所属项目', to='projects.Project', on_delete=models.CASCADE, related_name='interfaces')

    class Meta:
        db_table = 'tb_interface'
        verbose_name = 'interface'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name